import { defineStore } from 'pinia'
import { ref } from 'vue'

//用户模块  token,setToken,removeTolen
export const useUserStore = defineStore(
  'big-user',
  () => {
    const token = ref('')
    const userinfo=ref({ })
    const setToken = (newToken) => {
      token.value = 'JWT '+newToken
    }
    const removeTolen = () => {
      token.value = ''
    }
    const setinfo=(info)=>{
      userinfo.value=info
    }
    //用户信息获取
    // const user = ref({})
    // const getUser = async () => {
    //   const res = await userGetInfoService() // 请求获取数据
    //   user.value = res.data.data
    // }

    // const setUser = (obj) => {
    //   user.value = obj
    // }

    return {
      token,
      setToken,
      userinfo,
      removeTolen,
      setinfo
      // setUser
      // user,
      // getUser
    }
  },
  {
    persist: true
  }
)
